package likong.bibliothek.obj;

import java.io.Serializable;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.Session;

import com.sun.jersey.api.NotFoundException;

import db.HibernateHelper;

public class Autor implements Serializable {
	private static final long serialVersionUID = 1L;
	
	Integer authorID;
	String name;
	String vorname;
	Set<Buch> buch = new HashSet<Buch>();

	/*public static Autor fromID(int id) {

		Session session = HibernateHelper.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		Object author = session.get(Autor.class, id);
		session.close();
		if (author != null) {
			return (Autor)author;
		} else {
			throw new RuntimeException("Autor mit ID "+id+" in Datenbank nicht vorhanden");
		}
	}*/
	
	public Autor() {
	}

	public Autor(String name, String vorname) {
		this.name = name;
		this.vorname = vorname;
	}

	public Integer getAuthorID() {
		return authorID;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	public void setAuthorID(Integer authorID) {
		this.authorID = authorID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getVorname() {
		return vorname;
	}

	public void setVorname(String vorname) {
		this.vorname = vorname;
	}

	public Set<Buch> getBuch() {
		return buch;
	}

	public void setBuch(Set<Buch> buch) {
		this.buch = buch;
	}

}
